﻿using HDJ.Framework.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HDJ.Framework.Core.Editor
{
    public class TableDataDrawFieldBase
    {
        public virtual Type FieldType
        {
            get { return typeof(int); }
        }
        public virtual string Tag
        {
            get { return ""; }
        }
        public virtual void Init()
        {

        }

        public virtual object GetShowValue(object value, TableFieldInfo info)
        {
            return value;
        }
        public virtual object DrawGUI(string text, object value, TableFieldInfo info)
        {
            object v = EditorDrawGUIUtil.DrawBaseValue(text, value);
            if (info.fieldType.IsEnum)
            {
                string temp = EditorDrawGUIUtil.DrawBaseValue(text, value.ToString()).ToString();
                if (temp != value.ToString())
                {
                    List<string> list = new List<string>(Enum.GetNames(value.GetType()));
                    if (list.Contains(v))
                    {
                        v = Enum.Parse(value.GetType(), temp);
                    }
                }
            }
            return v;
        }


    }
}

